if(WIN32)
  add_definitions(-DUNICODE=1)
endif (WIN32)

if(MSVC)
  set_property(DIRECTORY PROPERTY CLR_EH_OPTION /EHa-s-)   # Native AOT runtime does not use C++ exception handling
  set_property(DIRECTORY PROPERTY CLR_CONTROL_FLOW_GUARD OFF)

  # The code generated by the Native AOT compiler doesn't work with Link Time Code Generation
  set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)

  # Sets the options that create the fastest code in the majority of cases
  add_compile_options($<$<AND:$<COMPILE_LANGUAGE:C,CXX>,$<CONFIG:Release>>:/O2>)
endif (MSVC)

if(CLR_CMAKE_HOST_UNIX)
  add_compile_options(-fno-exceptions)    # Native AOT runtime doesn't use C++ exception handling
  add_compile_options(-fno-asynchronous-unwind-tables)
  add_compile_options(-nostdlib)

  if(CLR_CMAKE_TARGET_APPLE)
    add_definitions(-D_XOPEN_SOURCE)
    add_definitions(-DFEATURE_OBJCMARSHAL)
  endif(CLR_CMAKE_TARGET_APPLE)

  if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
    # Allow 16 byte compare-exchange
    add_compile_options(-mcx16)
  endif(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386)
endif (CLR_CMAKE_HOST_UNIX)

if(CLR_CMAKE_TARGET_ANDROID)
    add_definitions(-DFEATURE_EMULATED_TLS)
endif()

add_subdirectory(Bootstrap)
add_subdirectory(Runtime)
